﻿using Mes.Domain.BoundedContext.EntityBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Domain.BoundedContext.Entities.Quality
{
    public class SpcRule : NoIdEntityBase
    {
        /// <summary>
        /// 规则描述
        /// Unique description of rule
        /// </summary>
        public string Rule_Desc { get; set; }

        public bool Use_For_Ix { get; set; } = false;

        public bool Use_For_Mr { get; set; } = false;

        public bool Use_For_Xbar { get; set; } = false;

        public bool Use_For_Range { get; set; } = false;

        public bool Use_For_Sigma { get; set; } = false;

        public bool Use_For_Ma { get; set; } = false;

        public bool Use_For_Ewmaix { get; set; } = false;

        public bool Use_For_Run { get; set; } = false;

        public bool Use_For_Attr { get; set; } = false;

        /// <summary>
        /// 对初级测试进行枚举，如果有1=趋势上升，2=趋势下降，3=高于，4=低于，5=低于，6=高于，7=交替约，8=能力sigma高于，9-Cpk高于，10=平均值高于，11=高于Ppk, 12=高于标准差
        /// Enumeration for primary test, if any 1=trend up,2=trend down,3=run above,4=run below,5=run within,6=run beyond,7=alternating about,8=capability sigma above,9-Cpk above, 10=mean above, 11=Ppk above, 12=standard deviation above
        /// </summary>
        public int? Test1 { get; set; }

        /// <summary>
        /// 二次检验枚举，如有1=趋势上升，2=趋势下降，3=高于，4=低于，5=低于，6=超过，7=交替约，8=低于能力sigma,9-Cpk低于，10=低于平均值，11=低于Ppk, 12=低于标准差
        /// Enumeration for secondary test, if any 1=trend up,2=trend down,3=run above,4=run below,5=run within,6=run beyond,7=alternating about,8=capability sigma below,9-Cpk below, 10=mean below, 11=Ppk below, 12=standard deviation below
        /// </summary>
        public int? Test2 { get; set; }

        /// <summary>
        /// 是，如果这两个条件都必须满足，则该过程被认为是失控的;如果其中一个足够，或者test1或test2为空，则不
        /// Yes if both conditions must be met for the process to be considered out-of-control; No if either is enough, or if either test1 or test2 is null
        /// </summary>
        public bool And_Not_Or { get; set; } = false;

        /// <summary>
        /// 标准偏差值适用于测试1(如果适用)。如果test1=3,4或6，则NULL =控制限制。当test1=9或11时，该值无量纲。如果test1=10，则value以特征为单位。
        /// Value in standard deviations to apply to test1 if applicable. If test1=3,4,or 6, NULL = control limits. If test1=9 or 11, value is dimensionless. If test1=10, value is in units of the characteristic.
        /// </summary>
        public float? Level1 { get; set; }

        /// <summary>
        /// 标准偏差值适用于测试2(如适用)。如果test2=3,4或6，则NULL =控制限制。当test2=9或11时，该值无量纲。如果test2=10，则value以特征为单位。
        /// Value in standard deviations to apply to test2 if applicable. If test2=3,4,or 6, NULL = control limits. If test2=9 or 11, value is dimensionless. If test2=10, value is in units of the characteristic.
        /// </summary>
        public float? Level2 { get; set; }

        /// <summary>
        /// 为了满足条件，必须满足标准的子组数量。
        /// Number of subgroups that must meet the critieria in order for the condition to be satisfied.
        /// </summary>
        public int Num_Points { get; set; }

        /// <summary>
        /// 一次要检查的子组数量，从num_points中获得
        /// Number of subgroups to check at a time, from with num_points are gotten
        /// </summary>
        public int Of_Points { get; set; }

        /// <summary>
        /// 违反规则的相对重要性，较低的数字比较高的数字更重要
        /// Relative importance of rule violations, lower numbers more important than higher
        /// </summary>
        public int Priority { get; set; }

        /// <summary>
        /// 是否不再使用
        /// Is this rule no longer used; default=No
        /// </summary>
        public bool Obsolete { get; set; } = false;

        /// <summary>
        /// 最新编辑原因
        /// Why record was changed
        /// </summary>
        public string? Last_Edit_Comment { get; set; }

        /// <summary>
        /// 最新编辑用户
        /// Who last changed record
        /// </summary>
        public string Last_Edit_By { get; set; } = String.Empty;

        /// <summary>
        /// 创建用户
        /// ID of user who created record
        /// </summary>
        public string Created_By { get; set; } = String.Empty;

        /// <summary>
        /// 最新编辑时间
        /// When record was last changed
        /// </summary>
        public DateTime Last_Edit_At { get; set; } = DateTime.Now;

        /// <summary>
        /// When record created, in GMT
        /// When record was last changed
        /// </summary>
        public DateTime Created_At { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 规则Id
        /// Identify rule; initially coded as follows: 0 = 1 sample outside control limit, 1  = 2 of 3 outside 2 standard deviations, 2= 3 of 7 outside 2 standard deviations, 3 = 4 of 10 outside 2 standard deviations, 4 = 4 of 5 outside 1 standard deviation, 5 = 7 consecutive samples on one side of centerline, 6 = 8  consecutive samples on one side of centerline, 7 = 8 consecutive samples beyond 1 standard deviation, 8 = 9 consecutive samples on one side of centerline, 9 = 10 of 11 on one side of centerline, 10 = 12 of 14 on one side of centerline, 11 = 6 consecutive samples increasing or decreasing, 12 = 7 consecutive samples increasing or decreasing
        /// </summary>
        public int Rule_Id { get; set; }

    }
}
